package vip.aning.gitsync.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.LoggerFactory;
import vip.aning.gitsync.service.GitClientService;

public class GitJob implements Job {
    private final org.slf4j.Logger LOG = LoggerFactory.getLogger(this.getClass());
    private final GitClientService gitClientService = new GitClientService();

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        LOG.info("GitJob execute...");
        // System.out.println(": doing something...");
        // 获取JobDetail的传参
        // System.err.println(jobExecutionContext.getJobDetail().getJobDataMap().get("name"));
        // System.err.println(jobExecutionContext.getJobDetail().getJobDataMap().get("age"));
        // 获取触发器Trigger的传参
        // System.err.println(jobExecutionContext.getTrigger().getJobDataMap().get("orderNo"));

        try {
            gitClientService.syncWithRemote();
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
        }

    }
}